﻿using System;
using System.Data;
using System.Data.Common;

//自定义命名空间
using DreamCube.Framework.DataAccess.Basic;
using DreamCube.Framework.DataAccess.Sqlserver;
using DreamCube.Foundation.Basic.Objects.Log;

namespace PicServer.DAL
{
    public static class FileTableFileIndex
    {
        /// <summary>
        /// 获取所有的索引数据
        /// </summary>
        /// <returns></returns>
        public static DataTable GetAllFileIndexData()
        {
            Database db = DbManager.GetDBByName(); 
            DbCommand command = db.GetSqlStringCommand("select tableName,fileIndex from FileTableFileIndex");
            return db.ExecuteDataTable(command);
        }

        /// <summary>
        /// 更新对应的文件索引序号
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="index"></param>
        public static void UpdateFileIndex(String tableName, Int32 index)
        {
            Database db = DbManager.GetDBByName();
            DbCommand command = db.GetSqlStringCommand(
                String.Format("update FileTableFileIndex set fileIndex={0} where tableName='{1}'", index, tableName));
            db.ExecuteNonQuery(command);
        }
    }
}
